rm(list=ls())

##############################################################################
# APPENDIX B3 TABLE 2
##############################################################################

# load packages
#library(texreg)

# load data 
load("data/candidate_GCI.RData")

##############
# RUN MODELS #
##############

LM1_bin <- lm(elected ~ ranking + factor(region), data = candidate_GCI)
#summary(LM1_bin)

LM2_bin <- lm(elected ~ ranking + factor(region) + log_gdp_percap, data = candidate_GCI)
#summary(LM2_bin)

LM3_bin <- lm(elected ~ ranking + factor(region) + log_gdp_percap + 
                log_pop + idealpoint_US + idealpoint_RU + nato_bin + eu_bin + g77_bin + oic_bin, data = candidate_GCI)
#summary(LM3_bin)

################
# CREATE TABLE #
################

appendB3_tab2 <- screenreg(list(LM1_bin,LM3_bin), custom.coef.map = list("votes" = "votes", 
                                                                 "ranking" = "ranking", 
                                                                 "log_gdp_percap" = "log GDP percap", 
                                                                 "log_pop" = "log population", 
                                                                 "idealpoint_US" = "UN voting (distance from US)", 
                                                                 "idealpoint_RU" = "UN voting (distance from Russia)",
                                                                 "nato_bin" = "NATO", 
                                                                 "eu_bin" = "EU", 
                                                                 "g77_bin" = "G77", 
                                                                 "oic_bin" = "OIC"),
                           omit.coef = c("region", "elect_year", "Constant"), 
                           custom.gof.rows = list("Region FE" = c("YES", "YES"), 
                                                  "Controls" = c("NO","YES")), digits = 3, 
                           stars = c(0.001, 0.01, 0.05, 0.1)) 

print(appendB3_tab2)

# script complete message 
print("appendB3_tab2 complete")